#GLOBAL
struct VSOutPSIn
{
	float4 Position_VSPS : SV_POSITION0;
	float2 Texcoord_VSPS : TEXCOORD0;
};
sampler Samplers[1];
float simulateSize;
float2 sampleOffsets[8];
texture2D MyTexture;
#END

#VS
struct VSIn
{
	float3 Position_VS : POSITION0;
	float2 Texcoord_VS : TEXCOORD0;
};


VSOutPSIn main(VSIn In)
{
	VSOutPSIn Out;

	Out.Position_VSPS = float4(In.Position_VS, 1);


	float2 uv = float2(In.Texcoord_VS.x, 1.0-In.Texcoord_VS.y);





	Out.Texcoord_VSPS = uv;




	return Out;
}
#END

#PS

struct PSOut
{
	float4 Color_PS : SV_TARGET0;
};

PSOut main(VSOutPSIn In)
{
	PSOut Out;

	float4 color = MyTexture.Sample(Samplers[0], In.Texcoord_VSPS);
	color = (color-0.5) * 2.0;

	float force = -color.z;
	for (int i = 0; i != 8; ++i)
	{
		float4 block = MyTexture.Sample(Samplers[0], In.Texcoord_VSPS + (sampleOffsets[i] * simulateSize));
		block = (block-0.5) * 2.0;

		force += (block.z - color.z);
	}
	color.x += force * 0.11111111111111111111111111111111;
	color.x *= .99;
	color.z += color.x;

	Out.Color_PS = (color+1.0) * 0.5;

	return Out;
}
#END

